import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

public class Cart {
    private Map<Fruit, Integer> fruits = new HashMap<>();

    public void addFruit(Fruit fruit, Integer kilo) {
        this.fruits.put(fruit, kilo);
    }

    public BigDecimal getTotalPrice() {
        BigDecimal total = BigDecimal.ZERO;
        for (Map.Entry<Fruit, Integer> fruitEntry : this.fruits.entrySet()) {
            Fruit fruit = fruitEntry.getKey();
            BigDecimal price = fruit.getPrice();
            Integer kilo = fruitEntry.getValue();
            BigDecimal oldPrice = new BigDecimal(kilo).multiply(price);
            total = total.add(oldPrice);
        }
        return total;
    }
}
